﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tester.DL645.Responses
{
    /// <summary>
    /// 
    /// </summary>
    public class HexGeneralReponse : AbstractReponse
    {

        /// <summary>
        /// 
        /// </summary>
        public HexGeneralReponse() { }

        /// <summary>
        /// 
        /// </summary>
        public decimal Value { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="buffer"></param>
        public HexGeneralReponse(byte[] buffer
            ,int valueLength 
            ,decimal factor=0.01m
            , int skipLength=14
            ) : base(buffer)
        {
            this.Value = (int.Parse(string.Join("", buffer.Skip(skipLength).Take(valueLength)
                .Select(item => (item - 0x33).ToString("X2"))))*factor);
            
        }
    }
}
